	mui.init()
			
			
			
		
			
			mui.plusReady(function(){
				document.getElementById('ex-phone').innerHTML = plus.webview.currentWebview().phone_num
				var timer = null 
				document.getElementById('get-vcode').addEventListener('tap',function(){
					var _self = this
					this.setAttribute('disabled',true)
					this.innerHTML = '重新发送(60秒)'
					var further = Date.now()+60000
					timer = setInterval(function(){
						var rest = ~~((further - Date.now())/1000)
						console.log(rest)
						_self.innerHTML = '重新发送('+rest+'秒)'
						if(rest<=0){
							clearInterval(timer)
							_self.innerHTML = '获取验证码'
							_self.removeAttribute('disabled')
						}
					},500)
					var http=getHttpHost();
					var phone=plus.webview.currentWebview().phone_num;
					$.post(http+'login/send',{phone:phone},function(d){
						if(d.code!=200){
							$.toast(d.msg)
						}else{
							window.localStorage.setItem('codeId',d.data);
						}
					})
						
				})
				
				document.getElementById('reg-ok').addEventListener('tap',function(){
					
					var http=getHttpHost();
					var dataform=collectForm()
					if(checkForm(dataform)){
						return false;
					}
					$.post(http+'login/reg',dataform,function(d){
						//if 注册成功自动登录
						if(d.code!=200){
							mui.toast(d.msg);
						}else{
							login_suc(d);
							var root = plus.webview.getWebviewById('login.html'),
							parent = plus.webview.getWebviewById('quick-reg.html')				
							mui.fire(root,'login_success',null)
							plus.webview.close(parent)
							mui.back()
						}
					
									
					
				})
				
			})
			})
			


//得到表单数据
function collectForm(){
	var dataform={};
	dataform.username=plus.webview.currentWebview().phone_num;

	dataform.password=$('#psw').val();
	dataform.code=$('#vcode').val();
	dataform.codeId=getuid('codeId');
	return dataform;
}

//表单验证
function checkForm(data) {

    var code = data.code;
    var codeId=data.codeId;
   
    if (code == '' ) {
        mui.toast('验证码不能为空');
        return true;
    }
    
    if (data.password == '') {
        mui.toast('密码不能为空');
        return true;
    }
    if (!codeId){
        mui.toast('验证码错误');
        return true;
    }
}